15. Quiz: Match Inputs To Outputs

Test Your Loop Knowledge

In case you want to test any code for the quizzes that follow, there is a code editor at the bottom of this page where you can experiment.

QUIZ QUESTION: :

Practice with range

For each below, match the input code to the appropriate output.

ANSWER CHOICES:



Input

Output

[4,6,8,10]

Error

[4,5,6,7]

[0,1,2,3]

[ ]

[1,2,3,4]

[0,1,2,3,4]

[1,2,3]

[4,6,8]

[4,5,6,7,8]

SOLUTION:

Input

Output

[4,5,6,7]

[0,1,2,3]

[ ]

[4,6,8]

Use the code below to complete the next quiz.

colors = ['Red', 'Blue', 'Green', 'Purple']
lower_colors = [ ]

for color in colors:
    #finish this part

If you want to create a new list called lower_colors , where each color in colors is lower cased, which code line should be inserted into the code block above?

SOLUTION: lower_colors.append(color.lower())

Start Quiz:

# Use the space here to practice whatever you would like pertaining to
# the above quizzes.